class Solution {
public:
unordered_map<int,int>mp;
int ans=0;
void dfs(vector<int>& nums,int k,int i)
{
    if(i==nums.size())
    {
        ans++;
        return ;
    }
    dfs(nums,k,i+1);
    if(mp[nums[i]+k]==0&&mp[nums[i]-k]==0)
    {
        mp[nums[i]]++;
        dfs(nums,k,i+1);
        mp[nums[i]]--;
    }
}

    int beautifulSubsets(vector<int>& nums, int k) {
        dfs(nums,k,0);
        return ans-1;
    }
};